﻿@inherits Nancy.ViewEngines.Razor.NancyRazorViewBase

@{
    ViewBag.Title = @Model.Title;
}

@section style{
    <link rel="stylesheet" href="~/Content/Css/index.css" />
}
<!--头部-->
<div class="header">
    <h1 class="fl dis pt15">@Model.ProgramName</h1>
    <ul class="fr header_right">
        <li class="fl" style="padding-right:0px;" id="li_RunState"><i class="fa fa-sun-o" style="color: #6BB4D5"></i> 运行状态</li>
        <li class="fl personal_information">
            <i class="fa fa-user" style="font-size: 16px;"></i> hi,<span>@Model.UserName <i class="fa fa-angle-double-down" style="font-size: 16px;"></i></span>
            <ul>
                <li id="li-changePwd"><a href="javascript:void(0)" class="navBar">修改密码</a></li>
            </ul>
        </li>
        <li class="fl"><a href="/Login/Exit"><i class="glyphicon glyphicon-off" style="color: #c60000"></i> 退出</a></li>
    </ul>
</div>

<div class="content">
    <!--左侧导航-->
    <div class="nav">
        <ul>
            <li class="menu_a">
                <a href="javascript:void(0)"><i class="fa fa-tasks"></i>任务管理</a>
                <ul class="menu_b">
                    <li><a href="javascript:void(0)" class="navBar" data-url="/Task/Grid">任务管理<span class="arr_r fr"></span></a></li>
                </ul>
            </li>           
            <li class="menu_a">
                <a href="javascript:void(0)"><i class="fa fa-gear"></i>系统管理</a>
                <ul class="menu_b">
                    <li><a href="javascript:void(0)" class="navBar" data-url="/Config/Grid">参数配置<span class="arr_r fr"></span></a></li>
                    <li><a href="javascript:void(0)" class="navBar" data-url="/Tool/SysLog">系统日志<span class="arr_r fr"></span></a></li>
                    <li><a href="javascript:void(0)" class="navBar" data-url="/Tool/ExceptionLog">异常消息<span class="arr_r fr"></span></a></li>
                </ul>
            </li>
            <li class="menu_a">
                <a href="javascript:void(0)"><i class="fa fa-desktop"></i>常用工具</a>
                <ul class="menu_b">
                    <li><a href="javascript:void(0)" class="navBar" data-url="/Tool/TableList">实体生成<span class="arr_r fr"></span></a></li>
                    <li><a href="javascript:void(0)" class="navBar" data-url="/Tool/CronExpress">Cron表达式<span class="arr_r fr"></span></a></li>
                    <li><a href="javascript:void(0)" class="navBar" data-url="/Tool/CommandLine">命令行<span class="arr_r fr"></span></a></li>
                </ul>
            </li>
        </ul>
    </div>
    <div id="right">
        <!--主体部分-->
        <iframe src="/DestTop" frameborder="0" allowtransparency="true" id="mainUrl"></iframe>
    </div>
</div>


<!--底部-->
<div class="myfooter">
    版权所有：<a href="http://yanweidie.cnblogs.com" target="_blank">焰尾迭</a>
</div>

<!-- 添加用户的对话框体 -->
<div class="modal fade" id="changePwdModal">
    <div class="modal-dialog">
        <div class="modal-content">
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
                <h4 class="modal-title userTitles">修改密码</h4>
            </div>
            <div class="modal-body">
                <input type="hidden" name="GroupType" id="form_GroupType" />
                <form id="changePwdForm" class="form-horizontal">
                    <div class="form-group">
                        <label class="col-sm-3 control-label"> <span style="color:red;">*</span>新密码：</label>
                        <div class="col-sm-8">
                            <input name="PasswordOne" id="txt_PasswordOne" maxlength="150" type="password" class="form-control" placeholder="请输入新密码"/>
                        </div>
                    </div>
                    <div class="form-group">
                        <label class="col-sm-3 control-label"> <span style="color:red;">*</span>确认密码：</label>
                        <div class="col-sm-8">
                            <input name="PasswordTwo" id="txt_PasswordTwo" maxlength="150" type="password" class="form-control"  placeholder="请输入确认密码" />
                        </div>
                    </div>
                </form>
            </div>
            <div class="modal-footer">
                <button id="btn_savePwd" type="submit" class="btn btn-primary btn-sm btn-confirm">保存</button>
                <button id="btn_saveAndClosePwd" type="submit" class="btn btn-primary btn-sm btn-confirm">保存并关闭</button>
                <button type="button" class="btn btn-white btn-sm" data-dismiss="modal">关闭</button>
            </div>
        </div>
    </div>
</div>

@section scripts{
    <script>
        $(function () {
            //左侧菜单展开收缩
            $('.menu_a').on('click', function (e) {
                e.stopPropagation();
                if ($(this).find('.menu_b').is(':hidden')) {
                    $(this).find('.menu_b').slideDown()
                } else {
                    $(this).find('.menu_b').slideUp();
                };
                $(this).siblings('.menu_a').find('.menu_b').slideUp();
                $('.menu_b li').removeClass('current');
            });
            $('.menu_b li').on('click', function (e) {
                e.stopPropagation();
                $(this).addClass('current').siblings().removeClass('current');
            });
            //点击切换菜单
            $('.navBar').on('click', function () {
                var url = $(this).attr('data-url');
                $('#mainUrl').attr({ src: url });
            });

            //系统运行状态
            $("#li_RunState").on("click", function () {
                $('#mainUrl').attr({ src: "/DestTop" });
                $('.menu_b li.current').closest('.menu_a').trigger("click");
            });

            var pwdForm = form = new Ywdsoft.Form("changePwdForm");
            $("#li-changePwd").on("click", function () {
                //显示
                $("#txt_PasswordOne").val('');
                $("#txt_PasswordTwo").val('');
                $("#changePwdModal").modal('show');                
            });

            //保存数据
            //参数 isCloseWin:是否关闭当前窗口
            function saveForm(isCloseWin) {
                isCloseWin = isCloseWin || false;
                var data = pwdForm.getData();
                if (data.PasswordOne == "") {
                    layer.tips("密码不能为空", "#txt_PasswordOne", {
                        tips: 3
                    });
                    return;
                }
                if (data.PasswordTwo == "") {
                    layer.tips("密码不能为空", "#txt_PasswordTwo", {
                        tips: 3
                    });
                    return;
                }
                if (data.PasswordOne != data.PasswordTwo) {
                    layer.tips("两次密码不一致", "#txt_PasswordTwo", {
                        tips: 3
                    });
                    return;
                }
                var index;
                $.ajax({
                    type: "post",
                    url: "/Home/ChgPwd",
                    data: { PasswordOne: data.PasswordOne, PasswordTwo: data.PasswordTwo },
                    dataType: "json",
                    beforeSend: function () {
                        index = layer.load(0);
                    },
                    complete: function () {
                        layer.close(index);
                    },
                    success: function (data) {
                        if (data.HasError) {
                            layer.alert(data.Message);
                            return;
                        }
                        if (isCloseWin) {
                            $('#changePwdModal').modal('hide');
                        } else {
                            layer.msg("密码修改成功");
                        }
                    }
                });
            };

            //保存按钮事件
            $("#btn_savePwd").on("click", function () {
                saveForm();
            });

            //保存按钮事件
            $("#btn_saveAndClosePwd").on("click", function () {
                saveForm(true);
            });
        });
    </script>
}